import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import nodejs from "@feidao/web/atom/browser/msg/nodejs";
import { generate } from '@feidao/core/querystring';
import fire_component_msg from '@feidao/web/atom/browser/fsm/fire-component-msg';

export default async function a020(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 删除回调
	// TODO 此示例为可以一次删除多条数据

	
	// TODO 和列表的复选框设置的data-feidao-name保持一致
	const c_boxs = fd.data.node.querySelectorAll('[data-feidao-name="certifi"]:checked');
	const ids: string[] = [];
	Array.from(c_boxs).forEach((ipt: HTMLInputElement) => {
		const id = ipt.getAttribute('data-feidao-id');
		ids.push(id);
	});
	// TODO 修改删除服务名称和参数
	const del_res = await nodejs(fd.data.spaceid, 'certifi_info_del', { ids });
	if (del_res === 'success') {
		// 重新渲染数据，删除分页条件
		const query = fd.data.params;
		delete query['page-no'];
		window.location.href = generate(query);
	} else {
		// alert('删除失败');
		fire_component_msg('zj-common-002', 'ec-001', 'fail', '删除失败');
	}
}
